﻿using Ocelot.Middleware;
using Ocelot.Multiplexer;
using System.IO;
using System.Net;
using System.Net.Http.Headers;
using System.Text;

namespace OcelotDemo.Aggregator
{
    public class FakeDefinedAggregator : IDefinedAggregator
    {
        public Task<DownstreamResponse> Aggregate(List<HttpContext> responses)
        {
            // 使用场景不多，官网信息也太少了~，懒得研究了
            var stringContent = new StringContent("{{data:\"自定义聚合器插入的信息\"}}")
            {
                Headers = { ContentType = new MediaTypeHeaderValue("application/json") }
            };

            return Task.Run(() =>
            {
                return new DownstreamResponse(stringContent, HttpStatusCode.OK, new List<Header>(), "reasonPhrase");
            });
        }
    }
}
